Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
JS: XHR loads files (>50MB) immediatly

I'm making a internet speedtest app with Node.js. Everything works fine expect the download test. I normally download at 8Mbits/s but when I try XHR requesting a text file / image (about 256 MByte) at /public/chunk/somefile.txt for example, it downloads it within 1 second which is impossible. Then I checked the onprogress log:

Image

How comes that it loads the image so fast? I mean it isnt cached or anything. Anyways here's the code:

const fileUrl= "/public/chunk/d.jpg";

xhr = new XMLHttpRequest();
xhr.onprogress = (e) => console.log(e, e.loaded - e.total);
xhr.onloadend = () => { console.log("end")};
xhr.open("GET", fileUrl, true);
xhr.setRequestHeader('Cache-Control','no-cache');
xhr.send();

BUT: Here's the thing, if I put in a image url for example: https://upload.wikimedia.org/wikipedia/commons/f/ff/Pizigani_1367_Chart_10MB.jpg . It works! Why?

Please let me know why it doesn't work, I've been trying around since 5 hours now. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you run the web server in on a local machine, the transfer rate is not limited to the rate your ISP provides in your area to access the WAN.

If you test it with another device in the same local network, 50MB might be nothing and will be transfered at half of a second or less.

  • A gigabit LAN connection can transfers up to 125MB/s
  • Wireless connections with 866MBit transfer up to 108MB/s

Depending on the hardware and network setup you can transfer larger files within seconds which may give you unexpected results on speedtests. You can throttle the download speed on the client side using the dev tools of the browser or plugins as mentioned in this answer.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!